<template>
  <div id="sheet1" class="mui-popover mui-popover-bottom mui-popover-action ">
    <!-- 可选择菜单 -->
    <ul class="mui-table-view">
      <li class="mui-table-view-cell">
        <a href="tel:051082611888">联系电话</a>
      </li>
      <li class="mui-table-view-cell">
        <a href="tel:4009288892">投诉电话</a>
      </li>
      <li class="mui-table-view-cell" @tap="goChat">
        <a href="#">在线客服</a>
      </li>
      <li class="mui-table-view-cell" @tap="goFeedback">
        <a href="#">意见反馈</a>
      </li>
    </ul>
    <!-- 取消菜单 -->
    <ul class="mui-table-view">
      <li class="mui-table-view-cell">
        <a href="#sheet1"><b  style="color:#ff6a27">取消</b></a>
      </li>
    </ul>
 </div>
</template>
<script>
import mui from 'static/js/mui'
import {addServiceToCustomer} from '@/api/user'
import storage from '@/utils/localstorage' 
export default {
  data() {
      return {
        chat: false,
      }
  },
  props: {
  },
  created() {
  },
  destroyed() {
  },
  components: {},
  methods: {  
    goFeedback(){
     document.body.removeChild(document.getElementsByClassName('mui-backdrop-action')[0])
      this.$router.push('feedback')
    },
    goChat() {
      let that = this
      let type = storage.getLocalstorage('user').serviceId
      if(type){
        document.body.removeChild(document.getElementsByClassName('mui-backdrop-action')[0])
        this.$router.push({
            name: "chat",
            params: {
              roomType: type
            }
        })
      }else{
        if(type == null){
          type = (Math.random() + 1).toFixed(0)
        }
        let mobile = storage.getLocalstorage('user').mobile
        if(!mobile){
          mui('#sheet1').popover('toggle');
          mui.alert('用户未注册', "消息提示", ['确定'],function() {
            that.$router.push('/login')
          },'div'); 
        }else{
          document.body.removeChild(document.getElementsByClassName('mui-backdrop-action')[0])
          let data = {serviceId: type, mobile: mobile}
          addServiceToCustomer(data).then(res=>{
            storage.setLocalstorage('user', res.data)
          })
          this.$router.push({
              name: "chat",
              params: {
                  roomType: type,
              }
          })
        }
      }
    }
  },
  mounted() {
      
  }
}
</script>

<style  scoped>

.mui-table-view-cell{
  padding: 13.5px 15px;
  background:#fff;
}
.mui-popover.mui-popover-action .mui-table-view{
  margin-left: 5%;
  margin-right: 5%; 
}
</style>
